<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/login.css" />
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<title>登录</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
   $(document).ready(function () {
      /**
       * 输入账号密码，到后端数据库查询，返回类型为整条用户信息对象user，登陆成功进入首页，将user作为参数带走
       */
      $("#login").click(function () {
         var login=$("[name='login']").val();
         var password=$("[name='password']").val();
         var emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
         var phonePattern = /^1[3-9]\d{9}$/;
         if(emailPattern.test(login)){
            var email = login;
            $.get("User/selectlogin",{"email":email,"password":password},function (user) {
               if (user.status==100){
                  alert("登录成功!");
                  localStorage.setItem("result",user.result);
                  var item = localStorage.getItem("result");
                  // var item1 = localStorage.getItem("result");

                  window.location.href="index1.html";
               }else{
                  alert("登录失败！,请重新输入！");
                  window.location.href="login.html";

               }
            });
         }else if (phonePattern.test(login)){
            var phone = login;
            $.get("User/selectlogin",{"phone":phone,"password":password},function (user) {
               if (user.status==100){
                  alert("登录成功!");
                  localStorage.setItem("result",user.result);
                  var item = localStorage.getItem("result");
                  window.location.href="index1.html";
               }else{
                  alert("登录失败！,请重新输入！");
                  window.location.href="login.html";
               }
            });
         }else {
            var username = login;
            $.get("User/selectlogin",{"username":username,"password":password},function (user) {
               if(user.status==100){
                  alert("登录成功!");
                  localStorage.setItem("result",user.result);
                  var item = localStorage.getItem("result");
                  window.location.href="index1.html";
               }else{
                  alert("登录失败！,请重新输入！");
                  window.location.href="login.html";
               }
            });
         }
      });

      /**
       * 单击”忘记密码“进入重置密码的password.html页面
       */
      $("#forgetpassword").click(function () {
         window.location.href="password.html";
      });

      /**
       * 注册按钮，点击后进入注册页面
       */
      $("#zhuce").click(function () {
         window.location.href="register.html";
      });
   });
</script>
</head>

<body>
<div class="header">
   <div class="mainwarp">
      <div class="logo"><a href="index.html"><img src="images/log.png" /></a></div>
      <div class="welcome">欢迎登录</div>
      <div class="headerright">
         <a href="index.html">返回首页</a>
      </div>
   </div>
</div>
<div class="content">
   <div class="logtype"></div>
   <div class="clear"></div>
   <div class="logoDiv">
      <div class="logoLeft">
         <div class="leftimg">
            <img src="images/log1.gif" />
         </div>
         <div class="leftcon">
            <a href="" class="a1">手机触屏版</a>
            <a href="" class="a2">Android客户端下载</a>
            <a href="" class="a3">iPhone客户端下载</a>
         </div>
      </div>
      <div class="logoRight">
         <div class="normalLogin">
            <div class="username">
               <span></span>
               <input  name="login" type="text" placeholder="请输入用户名/邮箱/已验证手机号"/>
            </div>
            <div class="password">
               <span></span>
               <input name="password" type="text" placeholder="请输入密码"/>
            </div>
            <div class="autoLogo">
               <a id="forgetpassword" class="pasd">忘记密码？</a>
            </div>
            <div class="autoLogo">
               <span class="CheckBox Yes"></span>
               <span>我已阅读并接受<a href="user_agreement.html">用户协议</a></span>
            </div>
            <div class="logobtn">
               <a id="login" >登  录</a>
            </div>
            <div class="zcbtn">
               <a id="zhuce">还没有账号？立即注册</a>
            </div>
         </div>
         <div class="weixinLogin">
            <div class="weixinQr">
               <img src="images/showqrcode.jpg" width="150" class="useHelpcon"/>
               <p>使用微信扫描上方二维码</p>
               <p class="useHelp useHelpcon">使用帮助</p>
            </div>
            <div class="zcbtn">
               <a>还没有账号？立即注册</a>
            </div>
         </div>
      </div>
   </div>
</div>





<div class="clear"></div>
</body>
</html>
